$(document).ready(function(){

    //屏蔽元素
    var removeEle = function (pathArr) {
      for(var i=0;i<pathArr.length;i++){
        var path = pathArr[i]
        var eleName = ''
        var ele = $(path)
        if(ele.length>0){
          ele.remove()
        }else {
          console.log('元素'+path+'不存在!')
        }
      }
      console.log('屏蔽完成')
    }
    var halloween = function(){
        console.log('js植入成功');
        var domain = document.domain;
        console.log('当前网站域名'+domain);
        //csdn广告屏蔽
        if(domain=="csdn.net"){
            let path = ["info-div","iframe","#q123",".recommend-ad-box","newsfeed",".light-box"]
            removeEle(path)
        }
        if(domain=="tieba.baidu.com"){//百度贴吧
            var ad = $(".l_post.l_post_bright.j_l_post.clearfix");//广告楼层
            var navTop = $("#thread_theme_5 a");//顶部导航栏
            var navFoot = $("#thread_theme_7 a");//底部导航栏
            if(ad.length>0){
              for (let i=0;i<ad.length;i++){
                  if(ad[i].className=="l_post l_post_bright j_l_post clearfix  "){
                        //一般楼层
                  }else{
                      //广告楼层
                      ad[i].remove();
                  }
              }
            }else{
                //console.log("ad 不存在")
            }
            if(navTop.length>0){//点击顶部导航栏的超链接
                // console.log(navTop);
                navTop.click(function () {
                    setTimeout(function(){
                        console.log("再次检查");
                        halloween();
                    },1500);
                });
            }else{
                //console.log("ele 不存在");
            }
            if(navFoot.length>0){//点击顶部导航栏的超链接
                // console.log(navFoot);
                navFoot.click(function () {
                    setTimeout(function(){
                        console.log("再次检查");
                        halloween();
                    },1500);
                });
            }else{
                //console.log("ele 不存在");
            }
        }
        //模板之家广告屏蔽
        if(domain=="www.cssmoban.com"){
            console.log("模板之家 开始屏蔽...")
            let path = [".col-item-ads",".adsbygoogle"]
            removeEle(path)
        }
        if(domain=="bbs.3dmgame.com"){
            console.log("3dm论坛 开始屏蔽")
            let path = [".a_cn"]
            removeEle(path)
        }
		// www.3dmgame.com
		if(domain=="www.3dmgame.com"){
		    console.log("3dm主站 开始屏蔽")
		    let path = ["iframe"]
		    removeEle(path)
		}
        console.log("END");
    };
    halloween();

});
